//
//  RBGoodsConfirmBillPopVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/9/8.
//

#import "RBGoodsConfirmBillPopVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import "RanTool.h"

@interface RBGoodsConfirmBillPopVC ()

@property(nonatomic, strong)UIView *needView;
@property(nonatomic, strong)UIView *noneedView;
@property(nonatomic, assign)BOOL need;

@end

@implementation RBGoodsConfirmBillPopVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.contentView = UIView.new;
    self.contentView.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:self.contentView];
    [self.contentView rbSetCorner:UIRectCornerTopLeft | UIRectCornerTopRight radius:Zoom(8)];
    
    UIImageView *closeBtn = [RanTool imgViewWithMode:0 radius:0 imgName:@"goodsDetailPramsClose"];
    [closeBtn extendResponseArea];
    [closeBtn rbAddTapGesWithTarget:self action:@selector(dismiss)];
    [self.contentView addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(Zoom(18));
        make.top.mas_equalTo(Zoom(22));
        make.right.mas_equalTo(-Zoom(16));
    }];
    
    [self.contentView view_addView:({
        UIView *view = UIView.new;
        [view rbAddTapGesWithTarget:self action:@selector(noNeedViewTapped)];
        self.noneedView = view;
        [view h_view_addView:({
            UIImageView *view = UIImageView.new;
            view.tag = 333;
            view;
        }) withHeight:Zoom(15) width:Zoom(15) top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(29) right:0 centerY:YES];
        [view h_view_addView:[RanTool labelWithFontSize:Zoom(16) weight:0 color:[RBThemeConfig textBlackColor] align:0 text:@"无需发票"] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:Zoom(10) right:CGFLOAT_MIN centerY:0];
        view;
    }) withHeight:Zoom(48) width:CGFLOAT_MIN top:Zoom(46) bottom:0 left:0 right:0 centerX:0];
    [self.contentView view_addView:({
        UIView *view = UIView.new;
        [view rbAddTapGesWithTarget:self action:@selector(needViewTapped)];
        self.needView = view;
        [view h_view_addView:({
            UIImageView *view = UIImageView.new;
            view.tag = 333;
            view;
        }) withHeight:Zoom(15) width:Zoom(15) top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(29) right:0 centerY:YES];
        [view h_view_addView:[RanTool labelWithFontSize:Zoom(16) weight:0 color:[RBThemeConfig textBlackColor] align:0 text:@"开具企业发票"] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:Zoom(10) right:CGFLOAT_MIN centerY:0];
        view;
    }) withHeight:Zoom(48) width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerX:0];
    [self.contentView view_addView:({
        UIView *view = UIView.new;
        view.backgroundColor = [RBThemeConfig lineGrayColor];
        view;
    }) withHeight:1 width:CGFLOAT_MIN top:Zoom(4) bottom:0 left:Zoom(24) right:Zoom(24) centerX:0];
    [self.contentView view_addView:({
        UIView *view = UIView.new;
        [view h_view_addView:({
            UIView *view = UIView.new;
            [view view_addView:({
                UIView *view = UIView.new;
                [view h_view_addView:({
                    UIView *view = [RanTool labelWithFontSize:Zoom(15) weight:3 color:[RBThemeConfig textBlackColor] align:0 text:@"大某某公司名称"];
                    [view addPriority:1];
                    view;
                }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerY:0];
                [view h_view_addView:({
                    UIView *view = [RanTool labelWithFontSize:Zoom(12) weight:0 color:UIColor.whiteColor align:1 text:@"默认" bgColor:[RBThemeConfig buttonBlueColor] radius:Zoom(1)];
                    [view addPriority:2];
                    view;
                }) withHeight:Zoom(16) width:Zoom(35) top:0 bottom:0 left:Zoom(13) right:0 centerY:0];
                [view h_view_addView:UILabel.new withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerY:0];
                view;
            }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:0 bottom:0 left:0 right:0 centerX:0];
            [view view_addView:[RanTool labelWithFontSize:Zoom(12) weight:0 color:[RBThemeConfig textGrayColor] align:0 text:@"税号154815121"] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(11) bottom:0 left:0 right:0 centerX:0];
            view;
        }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:0 right:0 centerY:YES];
        [view h_view_addView:[RanTool imgViewWithMode:1 radius:0 imgName:@"mine_arrow_right"] withHeight:Zoom(12) width:Zoom(7) top:CGFLOAT_MIN bottom:CGFLOAT_MIN left:Zoom(20) right:0 centerY:YES];
        view;
    }) withHeight:Zoom(72) width:CGFLOAT_MIN top:Zoom(8) bottom:0 left:Zoom(27) right:Zoom(27) centerX:0];
    [self.contentView view_addView:[RanTool labelWithFontSize:Zoom(15) weight:0 color:@"#454545" align:1 text:@"其他公司" bgColor:@"#E5E5E5" radius:Zoom(20)] withHeight:Zoom(40) width:CGFLOAT_MIN top:Zoom(20) bottom:0 left:Zoom(28) right:Zoom(23) centerX:0];
    [self.contentView view_addView:[RanTool labelWithFontSize:Zoom(15) weight:0 color:UIColor.whiteColor align:1 text:@"添加+" bgColor:[RBThemeConfig buttonBlueColor] radius:Zoom(20)] withHeight:Zoom(40) width:CGFLOAT_MIN top:Zoom(14) bottom:MAX(Zoom(30), kRBSafeBottomHeight) left:Zoom(28) right:Zoom(23) centerX:0];
    
    self.need = NO;
    
    self.view.backgroundColor = UIColor.clearColor;
    self.contentView.width = kRBMainScreenWidth;
    self.contentView.height = self.contentView.esSize.height;
    self.contentView.left = 0;
    self.contentView.top = kRBMainScreenHeight;
}

- (void)show
{
    [UIView animateWithDuration:0.15 animations:^{
        self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        self.contentView.bottom = kRBMainScreenHeight;
    }];
}

- (void)dismiss
{
    [UIView animateWithDuration:0.15 animations:^{
        self.view.backgroundColor = UIColor.clearColor;
        self.contentView.top = kRBMainScreenHeight;
    } completion:^(BOOL finished) {
        [self dismissViewControllerAnimated:NO completion:nil];
    }];
}


#pragma mark - Network

#pragma mark - Event

- (void)needViewTapped
{
    self.need = YES;
}

- (void)noNeedViewTapped
{
    self.need = NO;
}

#pragma mark - Setter

- (void)setNeed:(BOOL)need
{
    _need = need;
    UIImageView *needImgView = (UIImageView *)[self.needView viewWithTag:333];
    UIImageView *noNeedImgView = (UIImageView *)[self.noneedView viewWithTag:333];
    needImgView.image = [UIImage imageNamed:need? @"addressListDefault": @"unsel"];
    noNeedImgView.image = [UIImage imageNamed:!need? @"addressListDefault": @"unsel"];
}

#pragma mark - Getter

@end
